package com.task.manager.controller.rest;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.task.manager.domain.Task;
import com.task.manager.service.home.TaskService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@RequestMapping("/api/actuator")
@Api(value = "任务API")
public class ActuatorApi {
	@Autowired
	private TaskService taskService;

	@ApiOperation(value = "查询所有执行器", notes = "", httpMethod = "GET")
	@RequestMapping(value = "/queryAll", method = RequestMethod.GET)
	public List<Task> queryAll() {
		return taskService.queryAll();
	}

	@ApiOperation(value = "通过执行器名称或者执行器代码查询相关任务", notes = "", httpMethod = "GET")
	@RequestMapping(value = "/queryActuatorByParam", method = RequestMethod.GET)
	public List<Task> queryTaskByParam(@ApiParam(name = "taskCode", value = "执行器代码") @RequestParam("taskCode") String taskCode,
			@ApiParam(name = "taskName", value = "执行器名称") @RequestParam("taskName") String taskName) {
		return taskService.queryTaskByParam(taskCode, taskName);
	}
}
